#ifndef FGE_RANDOM_HPP
#define FGE_RANDOM_HPP

#include <stdint.h>

namespace fge
{

class Random
{
public:
	Random(uint32_t seed = 0);

	int32_t NextInt();
	int32_t NextInt(int32_t maximum);
	int32_t NextInt(int32_t minimum, int32_t maximum);

	float NextFloat();
	float NextFloat(float maximum);
	float NextFloat(float minimum, float maximum);

private:
	uint32_t x, y, z, w, v;

	// Note: This random number generator algorithm comes from George Marsaglia's usenet post on rng
	// If this link is broken, please notify someone so it can be corrected
	// http://school.anhb.uwa.edu.au/personalpages/kwessen/shared/Marsaglia03.html
	inline int32_t xorshift()
	{
		uint32_t t = (x ^ (x >> 7));
		x = y; y = z; z = w; w = v;
		v = (v ^ (v << 6)) ^ (t ^ (t << 13));
		return static_cast<int32_t>((((y + y + 1) * v) & 0x7fffffff));
	}
};

}

#endif//FGE_RANDOM_HPP
